package org.crazyit.album.web;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.*;

import org.crazyit.album.web.base.BaseServlet;

@WebServlet(urlPatterns = "/showImg")
public class ShowImgServlet extends BaseServlet {
    public void service(HttpServletRequest request
            , HttpServletResponse response) throws IOException, ServletException {
        String img = request.getParameter("img");
        HttpSession session = request.getSession(true);
        session.setAttribute("curImg", img);
        response.setContentType("text/javascript;charset=gbk");
        PrintWriter out = response.getWriter();
        out.println("$('#show').attr('src' , 'uploadfiles/" + img + "');");
    }
}
